const mysql = require('mysql');
let connection = mysql.createConnection({
    host: 'localhost',
    port:3306,
    user: 'root',
    password: 'root',
    database: 'zhoukaotow'
});
connection.connect(function (err) {
    if (!err) {
        console.log("数据库链接成功");
    }else{
        console.log("数据库链接失败");
    }
});
function Login(sql){
    return new Promise((resolve,reject)=>{
        connection.query(sql,(err,data)=>{
            resolve(data);
        })
    })
}
function Registry(sql){
    return new Promise((resolve,reject)=>{
        connection.query(sql,(err,data)=>{
            resolve(data);
        })
    })
}
function Add(sql){
    return new Promise((resolve,reject)=>{
        connection.query(sql,(err,data)=>{
            resolve(data);
        })
    })
}

function Updata(sql){
    return new Promise((resolve,reject)=>{
        connection.query(sql,(err,data)=>{
            resolve(data);
        })
    })
}
function Del(sql){
    return new Promise((resolve,reject)=>{
        connection.query(sql,(err,data)=>{
            resolve(data);
        })
    })
}
function Select(sql){
    return new Promise((resolve,reject)=>{
        connection.query(sql,(err,data)=>{
            resolve(data);
        })
    })
}
module.exports = {Login,Registry,Add,Updata,Del,Select}